home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1996 / MacHack 1996.toast / Hacks / Hacks ’92 / Procedure Call Logger / BP_EP.a next >
Encoding:
Text File  |  1992-06-03  |  1.7 KB  |  89 lines  |  [TEXT/MPS ]

  1. ;------------------------------------------------------------------------------
  2. ;
  3. ; FILENAME
  4. ;    BP_EP.a
  5. ;
  6. ; COPYRIGHT
  7. ;    Copyright © Marshall Clow 1992
  8. ;    All rights reserved. 
  9. ;
  10. ;    This file contains routines to replace the “trace” routines
  11. ;    in the library. Calls to these routines are generated by the compiler
  12. ;    at the begining and end of each procedure.
  13. ;
  14. ;--------------------------------------------------------------------------------
  15.  
  16.     INCLUDE    'Traps.a'
  17.     
  18.     STRING    ASIS
  19.     CASE    OBJ
  20.  
  21.     IMPORT    FindMacsBugName
  22.     IMPORT    BreakHere
  23.     
  24.     
  25. ;; called at the beginning of every routine
  26. %_BP    PROC    EXPORT
  27.     MoveM.L    D0/D1/D2/A0/A1, -(A7)    ; save the registers
  28.     jsr    BreakHere
  29.     Beq.s    @1
  30.     
  31.     Move.L    $14(A7), D0        ; 5 saved registers * 4 bytes per
  32.     Pea    ProcName
  33.     Move.L    D0, -(A7)        ; return address
  34.     jsr    FindMacsBugName
  35.     addq    #$8, A7        ; pop parameters
  36.     Tst.L    D0
  37.     beq.s    @1
  38.  
  39.     Lea    ProcName, A0
  40.     Move.B    (A0), D0
  41.     Move.B    #$20, (A0)
  42.     Lea    TheStr, A0
  43.     Add.B    #$7, D0
  44.     Move.B    D0, (A0)
  45.     Move.L    A0, -(A7)
  46.     _DebugStr
  47.     MoveM.L    (A7)+, D0/D1/D2/A0/A1    ; put the registers back
  48. @1    RTS
  49.  
  50. TheStr    DC.B    $07
  51.     DC.B    'Enter:'
  52. ProcName    DC.B    0
  53.     DC.L    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  54. JunkPtr    DC.L    0
  55.     ENDP
  56.     
  57. ;; called at the end of every routine
  58. ;; do I need to save the registers ?
  59. %_EP    PROC    EXPORT
  60.     MoveM.L    D0/D1/D2/A0/A1, -(A7)
  61.     jsr    BreakHere
  62.     Beq.s    @1
  63.  
  64.     Move.L    $14(A7), D0        ; 5 saved registers * 4 bytes per
  65.     Pea    ProcName
  66.     Move.L    D0, -(A7)        ; return address
  67.     jsr    FindMacsBugName
  68.     addq    #$8, A7        ; pop parameters
  69.     Tst.L    D0
  70.     beq.s    @1
  71.  
  72.     Lea    ProcName, A0
  73.     Move.B    (A0), D0
  74.     Move.B    #$20, (A0)
  75.     Lea    TheStr, A0
  76.     Add.B    #$6, D0
  77.     Move.B    D0, (A0)
  78.     Move.L    A0, -(A7)
  79.     _DebugStr
  80.     MoveM.L    (A7)+, D0/D1/D2/A0/A1
  81. @1    RTS
  82.  
  83. TheStr    DC.B    $06
  84.     DC.B    'Exit:'
  85. ProcName    DC.L    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  86. JunkPtr    DC.L    0
  87.     ENDP
  88.  
  89.     END